package org.hose.junit;

import cn.hutool.log.Log;
import cn.hutool.system.SystemUtil;
import org.hose.util.AppConstants;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.util.Optional;

/**
 * 命令行参数扩展
 */
public class CommandLineArgsExtension implements BeforeAllCallback {
    public static final Log LOG = Log.get(CommandLineArgsExtension.class);

    @Override
    public void beforeAll(ExtensionContext context) {
        // 用例文件名称
        Optional<String> fileName = context.getConfigurationParameter("fileName");
        SystemUtil.set("fileName", fileName.orElse(AppConstants.TESTCASE_TEMPLATE_XLSX));
        // 有头/无头
        Optional<String> headless = context.getConfigurationParameter("headless");
        SystemUtil.set("headless", headless.orElse("false"));
        LOG.error("==============fileName==== " + fileName.orElse("传入参数为空") + " ==========================");
    }
}